package com.hth.feign.provider;


import com.hth.feign.api.Person;
import com.hth.feign.api.PersonApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PersonProvider implements PersonApi {
    @Autowired
    Person person;

    @Override
    public String getName() {

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        if (person.getName() == null) {
            return "person is not initial";
        }

        return person.getName();
    }

    @Override
    public Person getPerson() {
        if (person == null) {
            return new Person(1, "hth", "man", "hehehe");
        }
        return person;
    }

    @Override
    public String setPerson(Person person) {
        this.person = person;
        return "success";
    }
}
